package com.example.myapplication1;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class MainFragmentAdapter extends FragmentPagerAdapter {

    public MainFragmentAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
    }

    public MainFragmentAdapter(FragmentManager supportFragmentManager) {
        super(supportFragmentManager);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        Fragment fragment=null;
        switch (position){
            case 0:
                //需要添加相应的Fragement函数
                fragment=new MsgFragment();
                break;
            case 1:
                fragment=new ContactFragment();
                break;
            case 2:
                fragment=new FindFragment();
                break;
            case 3:
                fragment=new MeFragment();
                break;
            default:break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return 4;
    }
}
